Passed
Pull Request — master (#17)
by
unknown
01:26
created

events.spec.js ➔ ... ➔ describe(ꞌinitializationꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 9.4285
1
const _ = require('lodash');
2
const expect = require('chai').expect;
3
const path = require('path');
4
const sinon = require('sinon');
5
6
const projectRoot = path.resolve(__dirname, '..', '..', '..', '..');
7
8
describe('events', () => {
9
  let runtime;
10
11
  before(() => {
12
    _.set(global, 'chrome.runtime', {
13
      onMessage: {
14
        addListener: sinon.spy(),
15
      },
16
    });
17
18
    runtime = global.chrome.runtime;
19
  });
20
21
  describe('initialization', () => {
22
    it('should bind to message events', () => {
23
      const initialCallCount = runtime.onMessage.addListener.callCount;
24
25
      // eslint-disable-next-line
26
      require(path.join(projectRoot, 'source', 'js', 'events'));
27
28
      expect(runtime.onMessage.addListener.callCount).to.be.greaterThan(initialCallCount);
29
    });
30
  });
31
});
32